{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "函数的返回值\n",
    "1.返回值的关键字：return 2.在其他的编程语言中，一般return一定要写，不写会报错；但是在python中，return可以不写，return默认为None\n",
    "\n",
    "1.编程语言中的函数一定有返回值 2.返回的结果是一个值\n",
    "\n",
    "def get_formatted_name(first_name,last_name):\n",
    "    \"\"\"返回整洁的姓名\"\"\"\n",
    "    full_name = first_name + ' '+ last_name\n",
    "    # print(full_name)\n",
    "    #函数的返回结果为full_name\n",
    "    return full_name\n",
    "get_formatted_name(\"Jia\",\"Qi\")\n",
    "# print(get_formatted_name(\"Jia\",\"Qi\"))\n",
    "\n",
    "def list_test(names):\n",
    "    \"\"\"函数输入一个列表\"\"\"\n",
    "    print(names)\n",
    "list_test([\"Jiaqi\",\"hy\",\"yue\"])\n",
    "['Jiaqi', 'hy', 'yue']\n",
    "def dict_test(request_header):\n",
    "    \"\"\"函数输入一个字典\"\"\"\n",
    "    print(request_header)\n",
    "\n",
    "    函数可以返回任意类型的值\n",
    "    返回值为一个集合\n",
    "def search4vowels(word):\n",
    "    \"\"\"Return a boolean based on any vowels found\"\"\"\n",
    "    vowels = set('aeiou')\n",
    "    found = vowels.intersection(set(word))\n",
    "    return found\n",
    "word = search4vowels('hello zhichao')\n",
    "print(word)\n",
    "{'e', 'o', 'a', 'i'}\n",
    "# 返回值为一个字典：def build_person(name,age,job):\n",
    "    \"\"\"返回一个字典，其中包含有关一个人的信息\"\"\"\n",
    "    person = {'name':name,'age':age,'job':job}\n",
    "    return person\n",
    "person = build_person('Jia',22,'teacher')\n",
    "print(person)\n",
    "{'name': 'Jia', 'age': 22, 'job': 'teacher'}\n"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 2
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython2",
   "version": "2.7.6"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 0
}